var maxScrollPoint = 3000;

$(document).ready(function() {
	
	$('#content').on('click','#sitesee', function (){
	if (login_sucess!=1){
	login_sucess=2;
	} else {
	login_sucess=1;}
	});
	
		
	$('#choise_app').on('click', '#mycarousel img', function() {
		maxScrollPoint = 5300;
		$('.buttonDown').css('display','none');
		$('#bt_step0').fadeIn();
		$('.alertframe').css('display','none');
		
	});
	
	$('#mainPushForm').on('click', '#step1', function() {
		maxScrollPoint = 7800;
		$('.buttonDown').css('display','none');
		$('#bt_step1').fadeIn();
		$('.alertframe').css('display','none');
	});
	
	$('#mainPushForm').on('click', '#step2', function() {
		maxScrollPoint = 10300;
		$('.buttonDown').css('display','none');
		$('#bt_step2').fadeIn();
		$('.alertframe').css('display','none');
	});
	
	$('#mainPushForm').on('click', '#step3', function() {
		maxScrollPoint = 12400;
		$('.buttonDown').css('display','none');
		$('#bt_step3').fadeIn();
		$('.alertframe').css('display','none');
	});
	
	$('#mainPushForm').on('click', '#step4', function() {
		maxScrollPoint = 15300;
	});
	/*---------------Button Next------*/
	$('#moveDownButtonContainer').on('click', '#bt_step0', function() {
		$("html, body").animate({ scrollTop: 3600 }, "slow");
		//$('#arrow0').fadeIn();
		})
	$('#moveDownButtonContainer').on('click', '#bt_step1', function() {
		$("html, body").animate({ scrollTop: 5900 }, "slow");
	})	
	
	$('#moveDownButtonContainer').on('click', '#bt_step2', function() {
		$("html, body").animate({ scrollTop: 8300 }, "slow");
	})	
	
	$('#moveDownButtonContainer').on('click', '#bt_step3', function() {
		$("html, body").animate({ scrollTop: 11000 }, "slow");
	})	
		
	
	
		
	function start() {
			$('.arrowDown0').animate({bottom:'+=20px'}, 800, 'linear', function(){$('.arrowDown0').animate({bottom:'-=20px'}, 800, 'linear',start); });
				}
	function start1() {
			$('.arrowDown1').animate({bottom:'+=20px'}, 800, 'linear', function(){$('.arrowDown1').animate({bottom:'-=20px'}, 800, 'linear',start1); });
				}
	function start2() {
			$('.arrowDown2').animate({bottom:'+=20px'}, 800, 'linear', function(){$('.arrowDown2').animate({bottom:'-=20px'}, 800, 'linear',start2); });
				}
	function start3() {
			$('.arrowDown3').animate({bottom:'+=20px'}, 800, 'linear', function(){$('.arrowDown3').animate({bottom:'-=20px'}, 800, 'linear',start3); });
				}
	
	start();
	start1();
	start2();
	start3();

	function stopScroll(){
	speechLogin(); //  call speechbubble ---------------------
	$(window).on("scroll mousewheel", function(e) {
		if ($(this).scrollTop() > maxScrollPoint){
			$(this).scrollTop(maxScrollPoint);  
			
			
			if($('.alertframe').css('display')=='none'){
			
			$('.alertframe').fadeIn(300).delay(3500).fadeOut(400);
			
			if($(this).scrollTop()==3000){
			$('#alert1').html('<p>"Wait you have not select your app, we can\'t go further until you do - please try again."</p>');
			} else if($(this).scrollTop()==5300){
			$('#alert2').html('<p>"Hang on! Are you sure this is what you want to send? Check Preview and try again or click next."</p>');
			} else if($(this).scrollTop()==7800){
			$('#alert3').html('<p>"Wait a Minute! - Are you sure you don\'t want to be more specific?"    Try Again or  Click Next</p>');
			} else if($(this).scrollTop()==10300){
			$('#alert4').html('<p>"Hold Up! - Are you sure you don\'t want to be more specific?"  Try Again or Click Next</p>');
			} else if($(this).scrollTop()==12400){
			$('#alert5').html('<p>"Hold Up! - Press PUSH button to send message or come back to change any parameter</p>');
			} else {
			$('.alertframe').fadeOut(200);
			}
			}
			
			
			
		  	e.preventDefault();  
		 	return false;
		}
	});
	}
	
	
	
	function stopScrollSightsee(){
	speechSightsee(); //  call speechbubble for Sightsee---------------------
	$(window).on("scroll mousewheel", function(e) {
		if ($(this).scrollTop() > maxScrollPoint){
			$(this).scrollTop(maxScrollPoint);  
			
			
			if($('.alertframe').css('display')=='none'){	
			$('.alertframe').fadeIn(300).delay(3500).fadeOut(400);
			
			if($(this).scrollTop()==3000){
			$('#alert1').html('<p>"Wait you have not downloaded the demo app, we cant go further until you do - please try again."</p>');
			} else if($(this).scrollTop()==5300){
			$('#alert2').html('<p>"Hang on! Are you sure this is what you want to send? Check Preview and try again or click next."</p>');
			} else if($(this).scrollTop()==7800){
			$('#alert3').html('<p>"Wait a Minute! - Are you sure you don\'t want to be more specific?"    Try Again or  Click Next</p>');
			} else if($(this).scrollTop()==10300){
			$('#alert4').html('<p>"Hold Up! - Are you sure you don\'t want to be more specific?"  Try Again or Click Next</p>');
			} else if($(this).scrollTop()==12400){
			$('#alert5').html('<p>"Hold Up! - Press PUSH button to send message or come back to change any parameter</p>');
			} else {
			$('.alertframe').fadeOut(200);
			}
			}
					
		  	e.preventDefault();  
		 	return false;
		}
	});
	}

	/* Scroll the background layers */
	function parallaxScroll(){
		var scrolled = $(window).scrollTop();
		var res = 0;
		
		/*------------clouds------------------*/
		$('#parallax-bg1').css('top',(0-(scrolled*.75))+'px');
		$('#cl-1').css('left',(120+(scrolled*.7))+'px');
		$('#parallax-bg2').css('top',(0-(scrolled*.75))+'px');
		$('#cl-2').css('left',(-180-(scrolled*.65))+'px');
		$('#parallax-bg3').css('top',(0-(scrolled*.75))+'px');
		
		/*--------------------------elevator- ----------- ---*/
		$('#elevator').css('top',(400-(scrolled*.005))+'px');
		if(scrolled <18000){
		$('#elevator').css('display','block');
		} else{$('#elevator').css('display','none');}
		
		/*--------------------campbellfall-----------------*/
		res = scrolled/100;
		var mod = Math.floor(res%2);
		$('#campbellfall').css('background-position',(-mod*344+'px 0px'));
		
		
		
		//$('#campbellfall').html('<p>'+scrolled+'</p><p>'+res+'</p><p>'+mod+'</p>');
		if (scrolled >= 10) {
			$('#campbellfall').css('display','block');
			$('#campbellwrpap').css('top',(150-(scrolled*.005))+'px');
			} else {
			$('#campbellfall').css('display','none');
		}
		
		/*-----------Circle Rotator---Step4------*/ 
		$('#radius1').css({'-webkit-transform':'rotate('+(0+scrolled*0.65)+'deg)', '-moz-transform':'rotate('+(0+scrolled*0.65)+'deg)', '-ms-transform':'rotate('+(0+scrolled*0.65)+'deg)','-o-transform':'rotate('+(0+scrolled*0.65)+'deg)'});
		$('#radius2').css({'-webkit-transform':'rotate('+(0-scrolled*0.25)+'deg)', '-moz-transform':'rotate('+(0-scrolled*0.25)+'deg)', '-ms-transform':'rotate('+(0-scrolled*0.25)+'deg)','-o-transform':'rotate('+(0+scrolled*0.25)+'deg)'});
		$('#radius3').css({'-webkit-transform':'rotate('+(0+scrolled*0.35)+'deg)', '-moz-transform':'rotate('+(0+scrolled*0.35)+'deg)', '-ms-transform':'rotate('+(0+scrolled*0.35)+'deg)','-o-transform':'rotate('+(0+scrolled*0.35)+'deg)'});
		
		/*--------------BG Circle------*/
		$('.bgradius1').css({'-webkit-transform':'rotate('+(0+scrolled*0.65)+'deg)', '-moz-transform':'rotate('+(0+scrolled*0.65)+'deg)', '-ms-transform':'rotate('+(0+scrolled*0.65)+'deg)','-o-transform':'rotate('+(0+scrolled*0.65)+'deg)'});
		$('.bgradius2').css({'-webkit-transform':'rotate('+(0-scrolled*0.25)+'deg)', '-moz-transform':'rotate('+(0-scrolled*0.25)+'deg)', '-ms-transform':'rotate('+(0-scrolled*0.25)+'deg)','-o-transform':'rotate('+(0+scrolled*0.25)+'deg)'});
		$('.bgradius3').css({'-webkit-transform':'rotate('+(0+scrolled*0.35)+'deg)', '-moz-transform':'rotate('+(0+scrolled*0.35)+'deg)', '-ms-transform':'rotate('+(0+scrolled*0.35)+'deg)','-o-transform':'rotate('+(0+scrolled*0.35)+'deg)'});
	}
	
	/*------Title in circle appear----*/
	 function titleShow(){
 var scroll = $(window).scrollTop();
  if (scroll>=10000) {
 $('#circle4 p').fadeIn(400);
 } else if (scroll>=7600) {
 $('#circle3 p').fadeIn(400);
 } else if (scroll>=5000) {
 $('#circle2 p').fadeIn(400);
 }else if(scroll>=2800){
  $('#circle1 p').fadeIn(400);
 }
  }
	
	
	
	$(window).bind('scroll',function(e){
    	titleShow();
		parallaxScroll();
		
		if(login_sucess==1){
		stopScroll();
		if($(window).scrollTop()>=12200){$('#push_button').fadeIn(400);}
		} else if(login_sucess==2){
		stopScrollSightsee();
		if($(window).scrollTop()>=12200){$('#push_button').fadeIn(400);}
		}
		//alert(login_sucess);
		
		
		
	  });
		
	
});


